#ifndef THREAD_H
#define THREAD_H

#include <pthread.h> 
#include <string.h>
#include "Log.h"
typedef int (*thread_func)(void *lpara);

class Thread {

public:
	Thread(thread_func func, const char *name, void *lpara);
	~Thread();

	typedef enum {
		THREAD_PRIORITY_LOW,
		THREAD_PRIORITY_NORMAL,
		THREAD_PRIORITY_HIGH
	} ThreadPriority;

	static void *s_thread_func(void *lpara);
	bool start();
	bool setThreadPriority(ThreadPriority priority = THREAD_PRIORITY_HIGH);
	void wait(int *status = NULL);
	void detach();
	bool isExited();

public:
	pthread_t m_tid;
	long tid;
	thread_func m_threadFunc;
	char m_name[32];
	void *m_lPara;
	int m_retval;
	
protected:
	bool m_created;
	bool m_joined;
};

#endif
